export interface AnyObject {
  [key: string]: any;
}

export interface WidgetProps {
  name: string;
  value: any;
  props?: any;
  options?: Option[];
  onChange?: (key: string, value: any) => void;
}
export type OperateBtnType = 'add' | 'edit' | 'delete' | 'detail';
export type Widget =
  | 'input'
  | 'select'
  | 'checkboxes'
  | 'radio'
  | 'number'
  | 'date'
  | 'time'
  | 'switch';

export interface Option {
  key: string | number;
  label: React.ReactNode;
  value: any;
}

export interface FilterListItem {
  name: string; // 表单key
  label: string;
  type: Widget;
  value: any;
  colSize?: number;
  options?: Option[];
  props?: AnyObject; // 表单项组件props
  onChange: (key: string, value: any) => void;
}
export type ButtonsConfig = {
  key: string;
  run: boolean; // 使用与否
  text: string; // 按钮配置文案
  input: string; // 按钮显示文案
  fn?: (data?: AnyObject) => void;
};
export interface Props {
  id?: string;
  isCanEdit?: boolean;
  addCheckCode?: string;
  list?: FilterListItem[];
  buttons?: ButtonsConfig[];
  children?: React.ReactNode | React.ReactNode[];
  style?: React.CSSProperties;
  onExpand?: (isExpand: boolean) => void;
  onSearch?: (params?: AnyObject) => void;
  onReset?: (params?: AnyObject) => void;
  onAdd?: (data: any) => void;
}

export interface ItemProps {
  index: number; // 从0开始
  colSize?: number;
  label?: string;
  children?: React.ReactNode | React.ReactNode[];
}
